package com.example.broad;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;

public class PhoneReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving
        // an Intent broadcast.
       //intent 持有bundle
        Intent is=intent;
         Bundle bd =  is.getExtras();
         Object ob[]= (Object[]) bd.get("pdus");
         //Toast.makeText(BroadActivity.this,"info",Toast.LENGTH_LONG);
        for(Object p:ob)
        {

            SmsMessage sm=SmsMessage.createFromPdu((byte[]) p,"");

            sm.getOriginatingAddress();
            sm.getDisplayMessageBody();
        }


    }
}
